home *** CD-ROM | disk | FTP | other *** search
- if #argv != 3
- echo >&2 usage $0 fromdir todir
- return 10
- endif
- local from=argv[1] to=argv[2] fromdev todev
-
- if index(from,":") < 0 # no absolute path for FROM?
- fromdev = devname(cwd)
- else
- fromdev = devname(from)
- endif
- if index(to,":") < 0 # no absolute path for TO?
- todev = devname(cwd)
- else
- todev = devname(to)
- endif
- if fromdev==todev # FROM & TO on same device?
- mv "$from" "$to" # if so, just rename the dir
- return status
- endif
- if -e "$to"
- local tail=from j
- if (j=rindex(from,'/'))>=0
- tail=right(from,strlen(from)-j-1)
- elseif (j=index(from,':'))>=0
- if j<strlen(from)-1
- tail=right(from,strlen(from)-j-1)
- endif
- endif
- if right(to,1)==':'
- to=cat(to,tail)
- else
- to=cat(to,'/',tail)
- endif
- if -e "$to" # if TO already exists
- echo $0: $to already exists
- return 10
- endif
- endif
- mkpath "$to"
- if status > 5
- return status
- endif
- cp -cur "$from" "$to"
- if status > 5 # any problems with the copy?
- return status
- endif
- rm -r $from
- # Mvdir is presented as is; no warrantee is either expressed or implied
- # as to it's suitability to any purpose whatsoever. You assume all the
- # risk for all damage, even if caused by a defect in the software,
- # no matter how awful.
-